with open('hamlet.txt', 'r', encoding='UTF-8') as file:
    # 获取内容
    content = file.read()
    content = content.lower()
    for ch in '\'!"#$%&()*+,-./:;<=>?@[\\]^_‘{|}~':
        content = content.replace(ch, ' ')
    # print(content)
    words = content.split()
    words_dict = {}
    for word in words:
        words_dict[word] = words_dict.get(word, 0) + 1
    list_sorted = sorted(words_dict.items(), key=lambda x: x[1], reverse=True)
    print(list_sorted[:10])
